using Avalonia.Data.Converters;
using Avalonia.Media;
using System;
using System.Globalization;

namespace IntegratedMeasuring.Utils;

public class ResultToColorConverter : IValueConverter
{
    public static readonly ResultToColorConverter Instance = new();

    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is int result)
        {
            return result switch
            {
                1 => new SolidColorBrush(Color.Parse("#D4EDDA")), // 浅绿色 - PASS
                0 => new SolidColorBrush(Color.Parse("#F8D7DA")), // 浅红色 - FAIL
                2 => new SolidColorBrush(Color.Parse("#E2E3E5")), // 浅灰色 - NULL
                _ => new SolidColorBrush(Color.Parse("#6C757D"))  // 灰色 - 默认
            };
        }
        
        return new SolidColorBrush(Color.Parse("#6C757D")); // 默认灰色
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
} 